﻿using QInjection.Injector.Contracts;
using Roslyn.Compilers.CSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace QInjection.Injector
{
    internal class RuleData
    {
        private Restriction _rule;
        private Branch? _branch;
        private Object _value;

        internal RuleData(Restriction rule, Branch? property)
        {
            _rule = rule;
            _branch = property;
        }

        internal void Set(int intvalue)
        {
            _value = intvalue;
        }

        internal void Set(Operator _operator)
        {
            _value = _operator;
        }

        internal void Set(string name)
        {
            _value = name;
        }

        internal void Set(Regex regex)
        {
            _value = regex;
        }

        internal void Set(Reference reference)
        {
            _value = reference;
        }

        public Restriction Rule { get { return _rule; } }
        public object Value { get { return _value;  } }

        //internal void Check(Type ntype, SimpleLambdaExpressionSyntax n)
        //{
        //    switch (_rule)
        //    {
        //        case RuleType.SupportedArity:
        //            {
        //                return;
        //            }
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}

        //internal void Check(Type ntype, BinaryExpressionSyntax node)
        //{
        //    switch (_rule)
        //    {
        //        case RuleType.SupportedOperator:
        //            {
        //                var qinjectionop = Factory.GetOperator(node.OperatorToken);
        //                return;
        //            }
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}

        //internal void Check(Type ntype, IdentifierNameSyntax node)
        //{
        //    switch (_rule)
        //    {
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}

        //internal void Check(Type ntype, LiteralExpressionSyntax node)
        //{
        //    switch (_rule)
        //    {
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}

        //internal void Check(Type ntype, ParameterSyntax node)
        //{
        //    switch (_rule)
        //    {
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}

        //internal void Check(Type ntype, MemberAccessExpressionSyntax node)
        //{
        //    switch (_rule)
        //    {
        //        case RuleType.SupportedName:
        //            {
        //                return;
        //            }
        //        case RuleType.SupportedNameRegex:
        //            {
        //                return;
        //            }
        //        default:
        //            throw new Exception(String.Format("Rule {0} Not Supported on {1}", _rule, ntype.FullName));
        //    }
        //}
    }
}
